package com.fa7.android.example.listafacil;

import android.database.Cursor;

public class Compra {
	private int mQtd;
	private double mValue;
	private String mName;
	private String mImageFilename = "";
	private Integer mId;
	
	Compra(String name, double value, int qtd, String filename) {
		mName = name;
		mValue = value;
		setQtd(qtd);
		mImageFilename = filename;
	}
	
	Compra(Cursor c) {
		mId = c.getInt(c.getColumnIndex("_id"));
		mName = c.getString(c.getColumnIndex("name"));
		mValue = c.getInt(c.getColumnIndex("value"));
		mImageFilename = c.getString(c.getColumnIndex("img_filename"));
		mQtd = c.getInt(c.getColumnIndex("qtd"));
	}
	
	public Integer getId() {
		return mId;
	}
	
	public void setId(Integer i) {
		mId = i;
	}
	
	public String getImgFilename() {
		return mImageFilename;
	}
	
	public void setImgFilename(String fn) {
		mImageFilename = fn;
	}
	
	public int getQtd() {
		return mQtd;
	}
	
	public void setQtd(int q) {
		if (q <= 0) {
			q = 1;
		}
		
		mQtd = q;
	}
	
	public String getName() {
		return mName;
	}
	
	public void setName(String n) {
		mName = n;
	}
	
	public double getValue() {
		return mValue;
	}
	
	public void setValue(double v) {
		mValue = v;
	}
		
}
